<% layout('/layouts/default.html', {title: 'TT付款单查询', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text('TT付款单详情')}
				<% if (ttPaymentOrder.arId != "" && ttPaymentOrder.apId != "" && hasPermi('financial:ttpaymentorder:ttPaymentOrder:sk')){ %>
				<button type="button" class="btn btn-primary" id="goPay"> ${text('付款')}</button>
				<% } %>
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ttPaymentOrder}" action="${ctx}/financial/ttpaymentorder/ttPaymentOrder/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('基本信息')}</div>
			<#form:hidden path="ttPaymentOrderId"/>
			<#form:hidden path="arId"/>
			<#form:hidden path="apId"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('编号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="paymentOrderCode" maxlength="100" class="form-control" placeholder="自动生成" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="serviceOrderId" items="${listServiceOrder}"
							itemLabel="serviceOrderCode" itemValue="serviceOrderId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('客户')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:treeselect id="customer" title="${text('客户选择')}"
							path="customer.customerId" labelPath="customer.customerName"
							url="${ctx}/base/customer/customer/treeData" canSelectRoot="true" canSelectParent="true"
							class=" " allowClear="true"   readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('资方')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="investorId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control " blankOption="true"  readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('外商')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="foreignBusinessmenId" items="${hwzfList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control " blankOption="true"  readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('外商银行账号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="foreignBusinessmenBank" maxlength="100" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('海外仓单据号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="overseasWarehouseCode" items="${listOverseasWarehouse}"
							itemLabel="overseasWarehouseCode" itemValue="overseasWarehouseId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('外商地址')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="foreignBusinessmenAddress" maxlength="100" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('银行名称')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="bank" maxlength="100" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('银行地址')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="bankAddress" maxlength="200" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('swift码')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="swiftCode" maxlength="200" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('TT付款单明细')}</h4>
			<div class="ml10 mr10">
				<table id="ttPaymentOrderDetailDataGrid"></table>
				<!--					<% if (hasPermi('financial:ttpaymentorder:ttPaymentOrder:edit')){ %>-->
				<!--					<a href="#" id="ttPaymentOrderDetailDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>-->
				<!--					<% } %>-->
			</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('保证金比例')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="marginRatio" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('已收保证金')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="marginReceived" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('币种')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="currency" dictType="sys_bizhong" blankOption="true" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('购汇金额')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="purchaseAmount" class="form-control required number" defaultValue="0" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('购汇汇率')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="purchaseExchangeRate" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('等值人民币价额')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="rmbEquivalent" class="form-control number" readonly="true" defaultValue="0" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('电报费')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="telegramFee" class="form-control number" defaultValue="0" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('手续费')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="handlingFee" class="form-control number" defaultValue="0" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('合计')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="total" class="form-control number" readonly="true" defaultValue="0"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('付汇日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="paymentDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('交易附言')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="transactionMemo" rows="4" maxlength="255" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('图片信息')}</h4>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">
							<span class="required hide">*</span> ${text('图片上传')}：</label>
						<div class="col-sm-10">
							<#form:fileupload id="uploadImage" bizKey="${ttPaymentOrder.id}" bizType="ttPaymentOrder_image"
							uploadType="image" class="" readonly="false" preview="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('附件信息')}</h4>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">
							<span class="required hide">*</span> ${text('附件上传')}：</label>
						<div class="col-sm-10">
							<#form:fileupload id="uploadFile" bizKey="${ttPaymentOrder.id}" bizType="ttPaymentOrder_file"
							uploadType="all" class="" readonly="false" preview="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('系统信息')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createBy" maxlength="64" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createDate" readonly="true" maxlength="20" class="form-control "
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateBy" maxlength="64" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
			</div>
		</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化TT付款单明细DataGrid对象
$("#ttPaymentOrderDetailDataGrid").dataGrid({

	data: ${toJson(ttPaymentOrder.ttPaymentOrderDetailList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'ttPaymentOrderDetailId', editable:true, hidden:true},
		{header:'${text("车辆")}', name:'tcar.carName', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
		{header:'${text("车架号")}', name:'frameNumber', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("车型")}', name:'model', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("外币单价")}', name:'unitPrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("等值人民币价额")}', name:'rmbEquivalent', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("电报费")}', name:'telegramFee', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("手续费")}', name:'handlingFee', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("TT付款单ID")}', name:'ttPaymentOrderId.ttPaymentOrderId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 1,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#ttPaymentOrderDetailDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {ttPaymentOrderDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'ttPaymentOrderDetailList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,ttPaymentOrderDetailId,carId,frameNumber,model,unitPrice,ttPaymentOrderId.ttPaymentOrderId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});

$('#goPay').click(function () {
	js.confirm('确认付款吗？', function(data){
		$.ajax({
			type: "POST",
			async : false,
			url: "${ctx}/financial/ttpaymentorder/ttPaymentOrder/goPay",
			data: {"ttPaymentOrderId": $("#ttPaymentOrderId").val(),
				"apId" : $("#apId").val(),
				"arId" : $("#arId").val(),
			},
			success: function (data) {
				js.showMessage(data.message);
				location.reload();
			}
		});
	});

})
</script>